﻿using System.Collections.Generic;

using UnityEngine;

#pragma warning disable CS0414 // 字段已被赋值，但它的值从未被使用

namespace ComponentAutoBind
{
    /// <summary>
    /// 组件自动绑定工具。
    /// </summary>
    public class ComponentAutoBindTool : MonoBehaviour
    {
        [SerializeField]
        private string m_ClassName;

        [SerializeField]
        private string m_Namespace;

        [SerializeField]
        private string m_ScriptFolderPath;

        [SerializeField]
        private string m_RuleHelperTypeName;

        [SerializeField]
        private string m_AuthorName;

        [SerializeField]
        private List<Component> m_BindComponents = new List<Component>();

        public T GetBindComponent<T>(int index) where T : Component
        {
            if (index >= m_BindComponents.Count)
            {
                Debug.LogError("索引无效");

                return null;
            }

            T bindComponent = m_BindComponents[index] as T;

            if (bindComponent != null)
            {
                return bindComponent;
            }

            Debug.LogError("类型无效");

            return null;
        }
    }
}